home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / reform15.zip / REFORMAT.IN3 < prev    next >
Text File  |  1987-05-23  |  7KB  |  168 lines

  1. {REFORMAT.IN3, aka FRAMER.INC }
  2. {PC-specific direct screen writing to create frames.
  3.  There are lots of examples on how to do this with Turbo and
  4.  regular "Write" if you have an odd video setup.
  5.  We make no effort to reduce "flicker" on slow or color
  6.  screens, since this is not a video-oriented utility.
  7.  Toad Hall.
  8. }
  9.  
  10. TYPE
  11.   Win_Set_Info
  12.     = RECORD
  13.         x,len,y,ht : Byte;
  14.       END;
  15.  
  16.   Window_Array  = ARRAY [0..2]
  17.                     OF Win_Set_Info;
  18. CONST
  19. win_set : Window_Array =  (
  20.            {      x  w  y  h }
  21.            {0}  ( x: 1; len:79; y: 1; ht:24),
  22.            {1}  ( x: 2; len:77; y:17; ht: 2),
  23.            {2}  ( x: 1; len:79; y: 2; ht:20)
  24.            );
  25.  
  26. VAR
  27.   color,
  28.   wLeft,wTop,
  29.   width,height,
  30.   ToadY        : INTEGER;
  31.  
  32. PROCEDURE Frame(nr : INTEGER);
  33.   BEGIN
  34.     InLine(
  35. {; window stack:}
  36. {;   0[win_set] = inner left edge of target window}
  37. {;   1[win_set] = length of target window}
  38. {;   2[win_set] = inner top edge of target window}
  39. {;   3[win_set] = height of target window}
  40.  
  41.    $1E             {   push    DS}
  42.   /$06             {   push    ES}
  43.  
  44.   /$B4/$0F         {   mov     AH,$0F     ;get current video mode}
  45.   /$CD/$10         {   int     $10}
  46.   /$89/$C3         {   mov     BX,AX}
  47.   /$B8/$00/$B0     {   mov     AX,$B000   ;assume mono}
  48.   /$80/$FB/$07     {   cmp     BL,7       ;mono?}
  49.   /$74/$03         {   je      S1         ; yep}
  50.   /$B8/$00/$B8     {   mov     AX,$B800   ; nope, color}
  51.                    {S1:}
  52.   /$8E/$C0         {   mov     ES,AX      ;ES=video memory}
  53.  
  54.   /$2E             {   CS:}
  55.   /$B8/>WIN_SET    {   mov     AX,>win_set;base of window array}
  56.   /$89/$C6         {   mov     SI,AX      ;DS:SI = array base}
  57.   /$8B/$46/$04     {   mov     AX,4[BP]   ;the window number parm}
  58.   /$09/$C0         {   or      AX,AX      ;0?}
  59.   /$74/$07         {   je      S2         ; yep}
  60.   /$BB/$04/$00     {   mov     BX,4       ;size of a window array}
  61.   /$F6/$E3         {   mul     BL         ;get offset in array 0..10}
  62.   /$01/$C6         {   add     SI,AX      ;DS:SI=window[wind_nr]}
  63.                    {S2:}
  64.   /$2E             {   CS:}
  65.   /$8B/$04         {   mov     AX,[SI]    ;AL=left edge, AH=width}
  66.   /$88/$E2         {   mov     DL,AH      ;keep width in DL}
  67.   /$A2/>WLEFT      {   mov     [>wLeft],AL;save in global}
  68.  
  69.   /$2E             {   CS:}
  70.   /$8B/$44/$02     {   mov     AX,2[SI]   ;AL=top edge,AH=height}
  71.   /$88/$E6         {   mov     DH,AH      ;keep height in DH}
  72.                    
  73.                    {;find starting address of window}
  74.   /$31/$C0         {   xor     AX,AX      ;clear msb}
  75.   /$89/$C3         {   mov     BX,AX}
  76.   /$2E             {   CS:}
  77.   /$8A/$44/$02     {   mov     al,2[SI]   ; top edge}
  78.   /$48             {   dec     AX}
  79.   /$A2/>WTOP       {   mov     [>wTop],AL ;save in global}
  80.  
  81.   /$B3/$A0         {   mov     bl,160     ;ax = top_edge*160 + lf_edge*2}
  82.   /$F6/$E3         {   mul     bl}
  83.   /$2E             {   CS:}
  84.   /$8A/$1C         {   mov     bl,[SI]    ;left edge}
  85.   /$4B             {   dec     BX}
  86.   /$D1/$E3         {   shl     BX,1}
  87.   /$00/$D8         {   add     al,bl}
  88.   /$80/$D4/$00     {   adc     ah,0}
  89.   /$89/$C7         {   mov     DI,ax      ;ES:DI= top left corner}
  90.   /$57             {   PUSH    DI         ;save for drawing verticals}
  91.                    {;find distance to bottom line of window}
  92.   /$31/$C0         {   xor     AX,AX      ;clear msb}
  93.   /$89/$C3         {   mov     BX,AX}
  94.   /$88/$F0         {   mov     al,DH      ; DH=height}
  95.   /$B3/$A0         {   mov     bl,160     ; ax = wd_height*160}
  96.   /$F6/$E3         {   mul     bl}
  97.   /$89/$C3         {   mov     bx,ax      ;BX=offset to bottom left}
  98.                    
  99.   /$8A/$26/>COLOR  {   mov     AH,[>color];get color back}
  100.   /$B0/$C9         {   mov     AL,$0C9  I ;top left corner,}
  101.   /$26             {   ES:}
  102.   /$89/$05         {   mov     [DI],AX    ;top left corner}
  103.   /$B0/$C8         {   mov     AL,$0C8    ;bottom left corner}
  104.   /$26             {   ES:}
  105.   /$89/$01         {   mov     [DI+BX],AX ;bottom left}
  106.   /$81/$C7/$02/$00 {   add     DI,2       ;bump to next scr word}
  107.                    
  108.   /$88/$D1         {   mov     cl,DL      ; get width of window, minus 2}
  109.   /$30/$ED         {   xor     ch,ch}
  110.   /$49             {   dec     cx}
  111.   /$B0/$CD         {   mov     al,$0CD    ; get horizontal line into ax}
  112.   /$50             {   push    AX         ;save for bottom}
  113.                    
  114.                    {;draw the 2 horizontals}
  115.   /$57             {   PUSH    DI         ;ES:DI = top left corner+1}
  116.   /$51             {   PUSH    CX}
  117.   /$F2/$AB         {   rep  stosw}
  118.   /$B0/$BB         {   mov     al,$0BB    ; top right corner}
  119.   /$26             {   ES:}
  120.   /$89/$05         {   mov     [DI],AX}
  121.   /$59             {   POP     CX}
  122.   /$5F             {   POP     DI         ;ES:DI=top left corner+1}
  123.  
  124.   /$58             {   pop     AX         ;horizontal line char}
  125.   /$01/$DF         {   add     DI,BX      ;now at bottom left+1}
  126.   /$F2/$AB         {   rep  stosw}
  127.                    
  128.   /$B0/$BC         {   mov     al,$0BC    ; bottom right corner}
  129.   /$26             {   ES:}
  130.   /$89/$05         {   mov     [DI],ax}
  131.                    
  132.   /$5F             {   POP     DI         ;get back window starting
  133.                                            address}
  134.   /$88/$D3         {   mov     bl,DL      ;get width of window minus 1
  135.                                            into bx}
  136.   /$30/$FF         {   xor     bh,bh}
  137.   /$D1/$E3         {   shl     bx,1}
  138.   /$81/$C7/$A0/$00 {   add     DI,160     ; move down a line (don't
  139.                                             overwrite corners)}
  140.   /$88/$F1         {   mov     cl,DH      ; get height of window, minus
  141.                                             2, into cx}
  142.   /$30/$ED         {   xor     ch,ch}
  143.   /$49             {   dec     cx}
  144.   /$B0/$BA         {   mov     al,$0BA    ; get vertical line into al}
  145.                    {;draw the two verticals}
  146.                    {V1:}
  147.   /$26             {   ES:}
  148.   /$89/$05         {   mov     [DI],ax    ;left side}
  149.   /$26             {   ES:}
  150.   /$89/$01         {   mov     [DI+BX],ax ;right side}
  151.   /$81/$C7/$A0/$00 {   add     DI,160     ;next row}
  152.   /$E2/$F4         {   loop    V1}
  153.  
  154.   /$31/$C0         {   xor     AX,AX}
  155.   /$88/$D0         {   mov     AL,DL}
  156.   /$2D/$01/$00     {   sub     AX,2}
  157.   /$A3/>WIDTH      {   mov     [>width],AX}
  158.   /$31/$C0         {   xor     AX,AX}
  159.   /$88/$F0         {   mov     AL,DH}
  160.   /$48             {   dec     AX}
  161.   /$A3/>HEIGHT     {   mov     [>height],AX}
  162.   /$B8/$01/$00     {   mov     AX,1       ;reset ToadY}
  163.   /$A3/>TOADY      {   mov     [>ToadY],AX ;to 1}
  164.   /$07             {   pop     ES}
  165.   /$1F             {   pop     DS}
  166. );
  167. END;  {of Frame}
  168.